package com.example.webview;

import android.content.Context;
import android.os.Build;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

/**
 * Created by dell on 2017/1/9 0009.
 */

public class MyClass {

    private Context context;

    public MyClass(Context context) {
        this.context = context;
    }


    @JavascriptInterface
    public void show(String data){
        Toast.makeText(context,"js调用的Android方法"+data,Toast.LENGTH_SHORT).show();
    }


    //不会被调用 缺少  @JavascriptInterface
    public void showOne(String data){
        Toast.makeText(context,"第二个了啊!"+data,Toast.LENGTH_SHORT).show();
    }

    //17以后必须添加次注解
    @JavascriptInterface
    public String getInfo(){

        return "手机型号: "+Build.DEVICE+"  手机API版本"+Build.VERSION.SDK_INT;
    }
}
